#include <iostream>
#include <memory>
using std::cout;
using std::endl;
using std::unique_ptr;

class Point
{
public:
    Point(int ix = 0,int iy = 0)
        : _ix(ix)
          , _iy(iy)
    {
        cout << "Point(int=0,int=0)" << endl;
    }

    void print() const{
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl; 
    }
private:
    int _ix;
    int _iy;
};

void test0(){
    //需要人为注意避免
    Point * pt = new Point(1,2);
    unique_ptr<Point> up(pt);
    unique_ptr<Point> up2(pt);
}

void test1(){
    unique_ptr<Point> up(new Point(1,2));
    unique_ptr<Point> up2(new Point(1,2));
    up.reset(new Point(8,9));
    up.reset(up2.get());
}

int main(void){
    test1();
    return 0;
}
